package com.yonyou.brigade.ybz.service.impl;

import com.yonyou.brigade.ybz.dao.ConvertTemplateMappingMapper;
import com.yonyou.brigade.ybz.model.ConvertTemplateMapping;
import com.yonyou.brigade.ybz.service.IConvertTemplateMappingService;
import com.yonyou.framework.base.service.impl.BaseServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConvertTemplateMappingServiceImpl extends BaseServiceImpl<ConvertTemplateMappingMapper, ConvertTemplateMapping> implements IConvertTemplateMappingService {

    /**
     * 获取所有的字段编码映射关系
     * @return
     */
    @Override
    public Map<String, String> queryALLConvertTemplateMapping() {
        Map<String, String> result = new HashMap<>();
        List<ConvertTemplateMapping> list = this.baseMapper.selectList(null);
        if(CollectionUtils.isNotEmpty(list)) {
            for (ConvertTemplateMapping convertTemplateMapping : list) {
                result.put(convertTemplateMapping.getTemplateColumn(),convertTemplateMapping.getConvertColumn());
            }
        }
        return result;
    }
}
